import * as api from "../../../api/company";
import * as company from "../../../api/company";

export default {
  namespace: "createdForm",

  state: {},

  effects: {
    * fetchBankList({ payload, callback }, { call, put }) {
      const response = yield call(api.bankList, payload);
      yield put({
        type: "bankList",
        payload: response.msg
      });
      if (callback) callback();
    },
    * getEnterpriseDesc({ payload }, { call, put }) {
      const response = yield call(company.enterpriseDetail, payload);
      yield put({
        type: "enterpriseDesc",
        payload: response.msg
      });
    },
    * submitStepForm({ payload,callback }, { call, put }) {
      console.log(payload);
      const response = yield call(api.SubmitForm, payload);
      yield put({
        type: "StepFormData",
        payload:response
      });
      if (callback) callback(response);
      // yield put(routerRedux.push("/form/step-form/result"));
    },
    * submitStepEdit({ payload,callback }, { call, put }) {
      console.log(payload);
      const response = yield call(api.SubmitEdit, payload);
      yield put({
        type: "StepFormData",
        payload:response
      });
      if (callback) callback(response);
      // yield put(routerRedux.push("/form/step-form/result"));
    }

  },

  reducers: {
    bankList(state, { payload }) {
      return {
        ...state,
        bankList: payload
      };
    },
    enterpriseDesc(state, { payload }) {
      return {
        ...state,
        desc: payload
      };
    },
    StepFormData(state, { payload }) {
      return {
        ...state,
        createData: payload
      };
    },
  }
};
